//Elderry 

$(document).ready(function () {
    $("input[type=submit], input[type=button], input[type=reset], button, .button").button().click(function (event) {
    });
    $("#methodSelector").buttonset();
    $('#methodSelector').change(function () {
        var radios = jQuery(this).children(":radio");
        var chosen;
        for (var chosen = 0; chosen < radios.length; chosen++) {
            if (radios[chosen].checked) {
                break;
            }
        }
        if (chosen == 0) {
            $("#accordion").accordion("option", "active", 2);
        }
        else {
            $("#accordion").accordion("option", "active", chosen - 1);
        }
    });
    $("#cycleSelector").buttonset();
    $("#cycleSetter").buttonset();
    $(".datepicker").datepicker();
    $(".progressbar").progressbar({
        value: 50
    });
    var beginHourSpinner = $("#beginHourSpinner").spinner();
    var beginMinuteSpinner = $("#beginMinuteSpinner").spinner();
    var cycleSpinner = $("#cycleSpinner").spinner();
    $("#accordion").accordion({
        collapsible: true,
        active: 2,
        activate: function (event, ui) {
            var decision = $("#accordion").accordion("option", "active");
            if (decision === false) {
                $("#onceMethod").get(0).checked = true;
            }
            else if (decision == 0) {
                $("#cycle_daily").get(0).checked = true;
                $("#cycleMethod").get(0).checked = true;
                $("#cycleSelector").buttonset("refresh");
            }
            else {
                $("#cycle_minute").get(0).checked = true;
                $("#customizeMethod").get(0).checked = true;
                $("#cycleSetter").buttonset("refresh");
            }
            $("#methodSelector").buttonset("refresh");
        }
    });
});
